package com.quan.OGCamera;

import com.example.test1.R;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.RelativeLayout.LayoutParams;


public class PositioningOverlayActivity extends Activity{
	private ImageView overlayImage;
	public void onCreate(Bundle savedInstanceState) {
	    super.onCreate(savedInstanceState);
	    setContentView(R.layout.overlay_positioning);
	    
	    
		ImageView background = (ImageView) findViewById(R.id.background);
		background.setImageBitmap(ImageManager.workingImage);
	    
		PositioningOverlayMultitouchView touchPad = (PositioningOverlayMultitouchView) findViewById(R.id.touchPad);
		overlayImage = (ImageView) findViewById(R.id.overlayImage);
		touchPad.overlayImage = overlayImage;
		// Get the fileUri passed with the intent
	    Bundle extras = getIntent().getExtras(); 	    

	    if (extras != null) {
	        Long id = (Long) extras.getLong("imageId");
	        String resourceName = "glass"+id;
	        //Merge image with a bullet hole image
	        if (id != 0) {
	        	//Bitmap overlay = BitmapFactory.decodeResource(this.getResources(), R.drawable.glass1);
				Bitmap bm = ImageManager.drawableToBitmap((ImageManager.getAndroidDrawable(resourceName,this.getBaseContext())));
				overlayImage.setImageBitmap(bm);
	        }
	        
	    }
	    
	}
	
	public void mergeButtonPressed(View view) {
		Intent intent = new Intent(this, ImageMergingActivity.class);
		Bundle extras = getIntent().getExtras();
		intent.putExtra("imageId", extras.getLong("imageId"));
		RelativeLayout.LayoutParams params = (LayoutParams) overlayImage.getLayoutParams();
		int leftMargin = params.leftMargin;
		int topMargin = params.topMargin;
		intent.putExtra("leftMargin", leftMargin);
		intent.putExtra("topMargin", topMargin);
		startActivity(intent);
	}
}
